package com.empresa.androidchkapp.pojos;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.empresa.androidchkapp.DataBaseHelper;

public class RespostaResolucao {
	private int id;
	private String Comentario;
	private String DataCadastro;
	private int RespostaId;
	private int IdServer;
	private int UsuarioId;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getComentario() {
		return Comentario;
	}

	public void setComentario(String comentario) {
		Comentario = comentario;
	}

	public String getDataCadastro() {
		return DataCadastro;
	}

	public void setDataCadastro(String dataCadastro) {
		DataCadastro = dataCadastro;
	}

	public int getRespostaId() {
		return RespostaId;
	}

	public void setRespostaId(int respostaId) {
		RespostaId = respostaId;
	}

	public int getIdServer() {
		return IdServer;
	}

	public void setIdServer(int idServer) {
		IdServer = idServer;
	}

	public int getUsuarioId() {
		return UsuarioId;
	}

	public void setUsuarioId(int usuarioId) {
		UsuarioId = usuarioId;
	}

	public RespostaResolucao RecuperaRespostaResolucao(Integer idServer, Context contexto) {

		String sql = "select * from RespostaResolucaos where IdServer = " + idServer;

		DataBaseHelper baseHelper = new DataBaseHelper(contexto);
		SQLiteDatabase db = baseHelper.getWritableDatabase();
		Cursor cursor = db.rawQuery(sql, null);

		cursor.moveToFirst();

		RespostaResolucao respResolucao = new RespostaResolucao();

		for (int i = 0; i < cursor.getCount(); i++) {

			Integer id = cursor.getInt(cursor.getColumnIndex("_id"));
			String comentario = cursor.getString(cursor.getColumnIndex("Comentario"));
			String dataCadastro = cursor.getString(cursor.getColumnIndex("DataCadastro"));
			Integer respostaId = cursor.getInt(cursor.getColumnIndex("RespostaId"));
			Integer idServerLocal = cursor.getInt(cursor.getColumnIndex("IdServer"));
			Integer usuarioId = cursor.getInt(cursor.getColumnIndex("UsuarioId"));
			
			respResolucao.setId(id);
			respResolucao.setComentario(comentario);
			respResolucao.setDataCadastro(dataCadastro);
			respResolucao.setRespostaId(respostaId);
			respResolucao.setIdServer(idServerLocal);
			respResolucao.setUsuarioId(usuarioId);
		}
		cursor.close();
		db.close();
		return respResolucao;

	}

}
